package com.leon.datalink.core.persistence.event;

/**
 * 数据处理事件
 * 当节点处理数据时触发
 * 
 * @author leon
 */
public class DataProcessedEvent implements NodeEvent {
    
    private String nodeId;
    private Object inputData;
    private Object outputData;
    private int portIndex;
    private long processingTime;
    private long timestamp;
    private String messageType;
    private long dataSize;
    
    public DataProcessedEvent() {
        // 默认构造函数，用于序列化
    }
    
    public DataProcessedEvent(String nodeId, Object inputData, Object outputData, int portIndex, long processingTime) {
        this.nodeId = nodeId;
        this.inputData = inputData;
        this.outputData = outputData;
        this.portIndex = portIndex;
        this.processingTime = processingTime;
        this.timestamp = System.currentTimeMillis();
    }
    
    @Override
    public String getNodeId() {
        return nodeId;
    }
    
    @Override
    public long getTimestamp() {
        return timestamp;
    }
    
    @Override
    public String getEventType() {
        return "DATA_PROCESSED";
    }
    
    public Object getInputData() {
        return inputData;
    }
    
    public Object getOutputData() {
        return outputData;
    }
    
    public int getPortIndex() {
        return portIndex;
    }
    
    public long getProcessingTime() {
        return processingTime;
    }
    
    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }
    
    public void setInputData(Object inputData) {
        this.inputData = inputData;
    }
    
    public void setOutputData(Object outputData) {
        this.outputData = outputData;
    }
    
    public void setPortIndex(int portIndex) {
        this.portIndex = portIndex;
    }
    
    public void setProcessingTime(long processingTime) {
        this.processingTime = processingTime;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public long getDataSize() {
        return dataSize;
    }

    public void setDataSize(long dataSize) {
        this.dataSize = dataSize;
    }
    
    @Override
    public String toString() {
        return "DataProcessedEvent{" +
                "nodeId='" + nodeId + '\'' +
                ", portIndex=" + portIndex +
                ", processingTime=" + processingTime +
                ", timestamp=" + timestamp +
                '}';
    }
}
